package mars;

import java.util.Scanner;


public class Main {
	public static void main(String[] s) {
		System.out.println("Enter top right plateu coordinates as x y. For e.g. 5 5");
		Scanner scan = new Scanner(System.in);
		String plateauCoord = scan.nextLine();
		try {
			InputParser.getInstance().definePlateu(plateauCoord);
		} catch (ParseException e1) {
			System.err.println(e1.getMessage());
			System.exit(-1);
		}
		
		String continueVar = "N";
		do {
			System.out.println("Enter initial rover position as x y direction. For e.g. 1 2 N");
			String initialRoverString = scan.nextLine();
			Position initialRoverPos = null;
			try {
				initialRoverPos = InputParser.getInstance().parsePositionString(initialRoverString);
			} catch (ParseException e1) {
				System.err.println(e1.getMessage());
				System.exit(-1);
			}
			Rover rover = new Rover(initialRoverPos);
			System.out.println("Enter command string as a list of commands. For e.g. LMLMLMLMM");
			try {
				rover.processCommand(scan.nextLine());
			} catch (OutOfBoundsException e) {
				System.err.println(e.getMessage());
				System.exit(-1);
			} catch (ParseException e) {
				System.err.println(e.getMessage());
				System.exit(-1);
			}
			System.out.println("The rover is looking at postion "+rover.getCurrentPosition());
			System.out.println("Do you want to assign another rover? Press Y to continue and N to exit");
			continueVar = scan.nextLine();
		} while(continueVar.equalsIgnoreCase("Y"));
	}
}
